﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HRM.DAL.DAO;
using HRM.DAL.Gateway;

namespace HRM.BLL
{
    public class SalaryManager
    {
        SalaryGateway gateway=new SalaryGateway();

        public string SaveEmployeeSalary(Salary salary)
        {
            EmployeeManager empManager=new EmployeeManager();
            int empId=empManager.GetEmployeeID(salary.Employee.EmpCode);
            if(gateway.IsSalaryStructureExistForThisEmployee(empId))
            {
                return "A Salary Structure Already Exists for this Employee, Please update the Structure";
            }
            else
            {
               return gateway.SaveEmployeeSalary(empId, salary);
            }
        }

        public string EditEmployeeSalary(Salary salary)
        {
            EmployeeManager empManager = new EmployeeManager();
            int empId = empManager.GetEmployeeID(salary.Employee.EmpCode);
            return gateway.EditEmployeeSalary(empId, salary);
        }

        public Salary GetEmployeeSalaryStructure(Code empCode)
        {
            EmployeeManager empManager = new EmployeeManager();
            int empId = empManager.GetEmployeeID(empCode);
            return gateway.GetEmployeeSalaryStructure(empId);
            
        }
    }
}